package org.example.demo.controller;

import org.example.demo.dao.UserDao;
import org.example.demo.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Collection;
import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {
    private UserDao userDao;

    @Autowired
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    @GetMapping
    public String getAllUser(Model model) {
        Collection<User> userList = userDao.getAllUser();
        model.addAttribute("userList", userList);
        return "user_list";
    }
}
